package Book;

public class Book {
    private String name;//书名
    private String author;
    private double price;
    private String type;//类型
    private boolean isBorrow = false;//是否被借阅

    //构造方法
    public Book(String name, String author, double price, String type ,boolean isBorrow) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
        this.isBorrow = isBorrow;
    }
    public Book(String name, String author, double price, String type ) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public boolean isBorrow() {
        return isBorrow;
    }

    public String getIsBorrow(){
        return (isBorrow == true) ? "true" : "false";
    }

    public void setBorrow(boolean borrow) {
        isBorrow = borrow;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    //重写toString方法
    @Override
    public String toString() {
        return "Book【" +
                "name = '" + name + '\'' +
                ", author = '" + author + '\'' +
                ", price = " + price +
                ", type = '" + type + '\'' +
                ", isBorrow = " + isBorrow +
                ((isBorrow == true) ? "  该图书已经被借出!" : "  该图书未被借出!") +
                '】';
    }
}
